home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / matrixc.zip / MATTEST.C < prev    next >
C/C++ Source or Header  |  1990-05-10  |  1KB  |  64 lines

  1. /* demo of use of matrix.c functions */
  2. /* Written by Nigel Salt */
  3.  
  4. #include <matrix.h>
  5. #include <stdio.h>
  6.  
  7. /* Matrix definitions */
  8. double b4x4A[4][4]=
  9. {
  10.   6,1,6,6,
  11.   1,6,6,0,
  12.   0,3,2,1,
  13.   8,6,1,9
  14. };
  15. matrix m4x4A={4,4,&b4x4A[0][0]};
  16.  
  17. double b4x4B[4][4];
  18. matrix m4x4B={4,4,&b4x4B[0][0]};
  19.  
  20. double b4x4C[4][4];
  21. matrix m4x4C={4,4,&b4x4C[0][0]};
  22.  
  23. double b4D[4];
  24. matrix cv4D={1,4,&b4D[0]};
  25.  
  26. double b4E[4];
  27. matrix cv4E={1,4,&b4E[0]};
  28.  
  29. double b4F[4];
  30. matrix rv4F={4,1,&b4F[0]};
  31.  
  32. double b4G[4];
  33. matrix rv4G={4,1,&b4G[0]};
  34.  
  35. double b3x3A[3][3]={0,1,1,1,2,3,1,1,1};
  36. matrix m3x3A={3,3,&b3x3A[0][0]};
  37.  
  38. double b3x3B[3][3]={0,1,1,1,2,3,1,1,1};
  39. matrix m3x3B={3,3,&b3x3B[0][0]};
  40.  
  41. double b3x3C[3][3]={0,1,1,1,2,3,1,1,1};
  42. matrix m3x3C={3,3,&b3x3C[0][0]};
  43.  
  44.  
  45. void main()
  46. {
  47.   int i,j;
  48.  
  49.   printf("\nMATRIX A");
  50.     mprint(&m4x4A);
  51.     printf("\nDET(A)=%lf",det(&m4x4A));
  52.     minv(&m4x4A,&m4x4C);
  53.   printf("\nINV(A)");
  54.     mprint(&m4x4C);
  55.     mmult(&m4x4A,&m4x4C,&m4x4B);
  56.   printf("\nMATRIX A*INV(A)");
  57.     mprint(&m4x4B);
  58.   mid(&m4x4B);
  59.   printf("\n4 x 4 ID MATRIX");
  60.     mprint(&m4x4B);
  61. }
  62.  
  63.  
  64.